home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 5⁄4⁄90 / 1218-Re Bug- non-unique f-Apr90 < prev    next >
Encoding:
Text File  |  1990-05-04  |  2.6 KB  |  93 lines  |  [TEXT/GEOL]

  1. Item forwarded  by  LOOMIS       to GUITTET1
  2.  
  3. Item forwarded  by  LOOMIS       to COWSAR1      PLUMMER1     REKIETA1
  4.  
  5. Item    8743492                         30-April-90        00:43PDT
  6.  
  7. From:   AUST0334                        AUDev - CRIA, Canberra, ACT,IDV
  8.  
  9. To:     MACAPP.TECH$                    MacApp Technical
  10.  
  11. Sub:    RE>Bug- non-unique fIdent
  12.  
  13. RE>RE>Bug: non-unique fIdent
  14.  
  15. Jesse,
  16.  
  17. (I didn't see your original link, just James Plamodon's reply)
  18.  
  19. Here is code that should provide Breadth First Searching of the view hierarchy,
  20. which should be fairly easy to install to your reqiuirements. (I haven't tested
  21. it, but the theory should be sound even if bits of the code are dubious.)
  22.  
  23.  FUNCTION TView.FindSubView (itsIdentifier: IDType): TView;
  24.  
  25.   VAR
  26.    i: integer;
  27.    StillSomeSubViews: BOOLEAN;
  28.    theAnswer: TView;
  29.  
  30.    { finds the sub view matching the identifier at the given level }
  31.   FUNCTION BreadthFindSubView (level: integer; theView: TView): TView;
  32.    VAR
  33.     theReturnedView: TView; { the view that has been found }
  34.    PROCEDURE CallBreadthFindSubView (theSubView: TView);
  35.    BEGIN
  36.     IF theReturnedView = NIL THEN { find the first one }
  37.      theReturnedView := BreadthFindSubView(level - 1, theSubView);
  38.    END;
  39.  
  40.   BEGIN
  41.    theReturnedView := NIL;
  42.    IF level = 0 THEN {the level to search is this level }
  43.    BEGIN
  44.     IF LONGINT(theView.fIdentifier) = LONGINT(itsIdentifier) THEN
  45.      theReturnedView := theView {! found the view }
  46.     ELSE
  47.     BEGIN { this is not the view }
  48.      IF fsubView <> NIL THEN
  49.       StillSomeSubViews := TRUE; { necessary to determine failure to find the
  50. view }
  51.     END
  52.    END
  53.    ELSE
  54.    BEGIN { search at a lower level than this one }
  55.     EachSubView(CallBreadthFindSubView);
  56.    END;
  57.    BreadthFindSubView := theReturnedView;
  58.   END;
  59.  
  60.  BEGIN{FindSubView  }
  61.   i := 0;
  62.   theAnswer := NIL;
  63.   REPEAT
  64.    StillSomeSubViews := FALSE;
  65.    theAnswer := BreadthFindSubView(i, SELF);
  66.    i := i + 1;
  67.   UNTIL (theAnswer <> NIL) OR (NOT stillSomeSubViews)
  68.   FindSubView := theAnswer;
  69.  END;
  70.  
  71.  
  72. A Minor Flame:
  73. As always, be cautious of bold assertions that something cannot be done in
  74. software. It harmeth not to admit that one does not know, or hasn't been able
  75. to get it to work. Stating unequivocally that something cannot be done may have
  76. a "chilling effect" on others, who might otherwise be willing to think about
  77. the problem a bit longer.
  78.  
  79. Flame Diminished:
  80. Re:  "C is the AntiChrist"... a message posted recently on AppleLink:
  81. I believe Pascal is excellent for teaching, but hopeless as a language to write
  82. programs in. (Though Inside MacApp should still use it as the example
  83. language).
  84.  
  85. "Modula-2 rules OK!"
  86.  
  87. Kenneth Beaton
  88. Canberra
  89. AUSTRALIA
  90.  
  91.  
  92.  
  93.